# include <iostream>
using namespace std;
int main ( )
{
  int n;
  for(n=7;n<500;n++)
	{  if (n%2==1&&n%3==2&&n%5==4&&n%6==5&&n%7==0)
		  {
			cout<<n<<endl;
			break;
			}	
	}
  cin>>n;
  return 0;
}